/*	

	EventHandler.h
	
	Definition of the event handler class
	used to handle all SDL events and user
	defined events within the game wrapper
	class.

	Written by Sigurd Suhm 2009
	
*/

#ifndef _EVENTHANDLER_H
#define _EVENTHANDLER_H

// Includes
#include <SDL/SDL.h>		// SDL main header
#include <vector>			// STL vector header

// Class forward declarations
class Game;
class IDevice;
class InputDevice;

namespace EraAstral
{
	namespace core
	{
		// Enumerator for event types
		typedef enum
		{
			EVENT_NONE = 0,
			EVENT_EXPOSE,
			EVENT_QUIT,
			EVENT_VIDEO_RESIZE,
			EVENT_KEY_PRESS,
			EVENT_KEY_RELEASE,
			EVENT_MOUSE_MOVE,
			EVENT_BUTTON_PRESS,
			EVENT_BUTTON_RELEASE
		} EventType;
		
		// Event structure
		struct Event
		{
			// Type of the event
			EventType type;
			// Event data
			char *data;
		};
	
		// Interface for objects affectable by events
		class IHasEvents
		{
			public:
				// Empty virtual destructor
				virtual ~IHasEvents() {}
				// Virtual method for handling event signal
				virtual void ProcessEventSignal(const Event *event) = 0;
		};
	
		// Event handler class
		class EventHandler
		{
			private:
				// Pointers to registered objects
				std::vector<IHasEvents *>	m_affectedObjects;
				// Event currently being processed
				Event *curEvent;
		
			public:
				// Default constructor
				EventHandler();
				// Default destructor
				~EventHandler();
				
				// Processes all pending events
				void ProcessEvents();
				
				// Methods for registering objects with the event handler
				void RegisterAffectedObject(IHasEvents *object);
		};
	}
}

#endif		// _EVENTHANDLER_H
